Skip to content

KBE3D / KBCore / turf

turf

函数

函数描述
alongTakes a LineString and returns a Point at a specified distance along the line.
angleFinds the angle formed by two adjacent segments defined by 3 points. The result will be the (positive clockwise) angle with origin on the startPoint-midPoint segment, or its explementary angle if required.
areaCalculates the geodesic area in square meters of one or more polygons.
bboxCalculates the bounding box for any GeoJSON object, including FeatureCollection. Uses geojson.bbox if available and options.recompute is not set.
bboxClipTakes a Feature and a bbox and clips the feature to the bbox using lineclip. May result in degenerate edges when clipping Polygons.
bboxPolygonTakes a bbox and returns an equivalent polygon.
bearingTakes two Point|points and finds the geographic bearing between them, i.e. the angle measured in degrees from the north line (0 degrees)
bezierSplineTakes a line and returns a curved version by applying a Bezier spline algorithm.
booleanClockwiseTakes a ring and return true or false whether or not the ring is clockwise or counter-clockwise.
booleanConcaveTakes a polygon and return true or false as to whether it is concave or not.
booleanContainsTests whether geometry a contains geometry b. The interiors of both geometries must intersect, and the interior and boundary of geometry b must not intersect the exterior of geometry a. booleanContains(a, b) is equivalent to booleanWithin(b, a)
booleanCrossesBoolean-Crosses returns True if the intersection results in a geometry whose dimension is one less than the maximum dimension of the two source geometries and the intersection set is interior to both source geometries.
booleanDisjointBoolean-disjoint returns (TRUE) if the intersection of the two geometries is an empty set.
booleanEqualDetermine whether two geometries of the same type have identical X,Y coordinate values. See http://edndoc.esri.com/arcsde/9.0/general_topics/understand_spatial_relations.htm
booleanIntersectsBoolean-intersects returns (TRUE) if the intersection of the two geometries is NOT an empty set.
booleanOverlapCompares two geometries of the same dimension and returns true if their intersection set results in a geometry different from both but of the same dimension. It applies to Polygon/Polygon, LineString/LineString, Multipoint/Multipoint, MultiLineString/MultiLineString and MultiPolygon/MultiPolygon.
booleanParallelBoolean-Parallel returns True if each segment of line1 is parallel to the correspondent segment of line2
booleanPointInPolygonTakes a Point and a Polygon or MultiPolygon and determines if the point resides inside the polygon. The polygon can be convex or concave. The function accounts for holes.
booleanPointOnLineReturns true if a point is on a line. Accepts a optional parameter to ignore the start and end vertices of the linestring.
booleanTouchesBoolean-touches true if none of the points common to both geometries intersect the interiors of both geometries.
booleanValidbooleanValid checks if the geometry is a valid according to the OGC Simple Feature Specification.
booleanWithinTests whether geometry a is contained by geometry b. The interiors of both geometries must intersect, and the interior and boundary of geometry a must not intersect the exterior of geometry b. booleanWithin(a, b) is equivalent to booleanContains(b, a)
bufferhttp://turfjs.org/docs/#buffer
centerTakes a Feature or FeatureCollection and returns the absolute center point of all features.
centerMeanTakes a Feature or FeatureCollection and returns the mean center. Can be weighted.
centerMedianTakes a FeatureCollection of points and calculates the median center, algorithimically. The median center is understood as the point that is requires the least total travel from all other points.
centerOfMassTakes any Feature or a FeatureCollection and returns its center of mass using this formula: Centroid of Polygon.
centroidComputes the centroid as the mean of all vertices within the object.
circleTakes a Point and calculates the circle polygon given a radius in Units; and steps for precision.
cleanCoordsRemoves redundant coordinates from any GeoJSON Geometry.
cloneReturns a cloned copy of the passed GeoJSON Object, including possible 'Foreign Members'. ~3-5x faster than the common JSON.parse + JSON.stringify combo method.
getClusterGet Cluster
clusterEachclusterEach
clusterReduceReduce clusters in GeoJSON Features, similar to Array.reduce()
clustersDbscanTakes a set of points and partition them into clusters according to [https://en.wikipedia.org/wiki/DBSCAN|DBSCAN's](https://en.wikipedia.org/wiki/DBSCAN
clustersKmeansTakes a set of points and partition them into clusters using the k-mean . It uses the k-means algorithm
collectMerges a specified property from a FeatureCollection of points into a FeatureCollection of polygons. Given an inProperty on points and an outProperty for polygons, this finds every point that lies within each polygon, collects the inProperty values from those points, and adds them as an array to outProperty on the polygon.
combineCombines a FeatureCollection of Point, LineString, or Polygon features into MultiPoint, MultiLineString, or MultiPolygon features.
concaveTakes a set of points and returns a concave hull Polygon or MultiPolygon. Internally, this uses turf-tin to generate geometries.
convexTakes a Feature or a FeatureCollection and returns a convex hull Polygon.
destinationTakes a Point and calculates the location of a destination point given a distance in degrees, radians, miles, or kilometers; and bearing in degrees. This uses the Haversine formula to account for global curvature.
differenceFinds the difference between multiple polygons by clipping the subsequent polygon from the first.
dissolveDissolves a FeatureCollection of Polygon features, filtered by an optional property name:value. Note that MultiPolygon features within the collection are not supported
distanceCalculates the distance between two coordinates in degrees, radians, miles, or kilometers. This uses the Haversine formula to account for global curvature.
distanceWeight-
ellipseTakes a Point and calculates the ellipse polygon given two semi-axes expressed in variable units and steps for precision.
envelopeTakes any number of features and returns a rectangular Polygon that encompasses all vertices.
explodeTakes a feature or set of features and returns all positions as points.
flattenFlattens any GeoJSON to a FeatureCollection inspired by geojson-flatten.
flipTakes input features and flips all of their coordinates from [x, y] to [y, x].
geojsonRbushGeoJSON implementation of RBush spatial index.
greatCircleCalculate great circles routes as LineString or MultiLineString. If the start and end points span the antimeridian, the resulting feature will be split into a MultiLineString. If the start and end positions are the same then a LineString will be returned with duplicate coordinates the length of the npoints option.
featureWraps a GeoJSON Geometry in a GeoJSON Feature.
geometryCreates a GeoJSON Geometry from a Geometry string type & coordinates. For GeometryCollection type use helpers.geometryCollection
pointCreates a Point Feature from a Position.
pointsCreates a Point FeatureCollection from an Array of Point coordinates.
polygonCreates a Polygon Feature from an Array of LinearRings.
polygonsCreates a Polygon FeatureCollection from an Array of Polygon coordinates.
lineStringCreates a LineString Feature from an Array of Positions.
lineStringsCreates a LineString FeatureCollection from an Array of LineString coordinates.
featureCollectionTakes one or more Features and creates a FeatureCollection.
multiLineStringCreates a Feature<MultiLineString> based on a coordinate array. Properties can be added optionally.
multiPointCreates a Feature<MultiPoint> based on a coordinate array. Properties can be added optionally.
multiPolygonCreates a Feature<MultiPolygon> based on a coordinate array. Properties can be added optionally.
geometryCollectionCreates a Feature<GeometryCollection> based on a coordinate array. Properties can be added optionally.
roundRound number to precision
radiansToLengthConvert a distance measurement (assuming a spherical Earth) from radians to a more friendly unit. Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
lengthToRadiansConvert a distance measurement (assuming a spherical Earth) from a real-world unit into radians Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
lengthToDegreesConvert a distance measurement (assuming a spherical Earth) from a real-world unit into degrees Valid units: miles, nauticalmiles, inches, yards, meters, metres, centimeters, kilometres, feet
bearingToAzimuthConverts any bearing angle from the north line direction (positive clockwise) and returns an angle between 0-360 degrees (positive clockwise), 0 being the north line
azimuthToBearingConverts any azimuth angle from the north line direction (positive clockwise) and returns an angle between -180 and +180 degrees (positive clockwise), 0 being the north line
radiansToDegreesConverts an angle in radians to degrees
degreesToRadiansConverts an angle in degrees to radians
convertLengthConverts a length from one unit to another.
convertAreaConverts an area from one unit to another.
isNumberisNumber
isObjectisObject
hexGridTakes a bounding box and the diameter of the cell and returns a FeatureCollection of flat-topped hexagons or triangles (Polygon features) aligned in an "odd-q" vertical grid as described in Hexagonal Grids.
interpolateTakes a set of points and estimates their 'property' values on a grid using the Inverse Distance Weighting (IDW) method.
intersectTakes polygon or multi-polygon geometries and finds their polygonal intersection. If they don't intersect, returns null.
getCoordUnwrap a coordinate from a Point Feature, Geometry or a single coordinate.
getCoordsUnwrap coordinates from a Feature, Geometry Object or an Array
containsNumberChecks if coordinates contains a number
geojsonTypeEnforce expectations about types of GeoJSON objects for Turf.
featureOfEnforce expectations about types of Feature inputs for Turf. Internally this uses geojsonType to judge geometry types.
collectionOfEnforce expectations about types of FeatureCollection inputs for Turf. Internally this uses geojsonType to judge geometry types.
getGeomGet Geometry from Feature or Geometry Object
getTypeGet GeoJSON object's type, Geometry type is prioritize.
isobandsTakes a square or rectangular grid FeatureCollection of Point features with z-values and an array of value breaks and generates filled contour isobands.
isolinesTakes a grid FeatureCollection of Point features with z-values and an array of value breaks and generates isolines.
kinksTakes a linestring, multi-linestring, multi-polygon or polygon and returns points at all self-intersections.
lengthTakes a GeoJSON and measures its length in the specified units, (Multi)Point's distance are ignored.
lineArcCreates a circular arc, of a circle of the given radius and center point, between bearing1 and bearing2; 0 bearing is North of center point, positive clockwise.
lineChunkDivides a LineString into chunks of a specified length. If the line is shorter than the segment length then the original line is returned.
lineIntersectTakes any LineString or Polygon GeoJSON and returns the intersecting point(s).
lineOffsetTakes a line and returns a line at offset by the specified distance.
lineOverlapTakes any LineString or Polygon and returns the overlapping lines between both features.
lineSegmentCreates a FeatureCollection of 2-vertex LineString segments from a (Multi)LineString or (Multi)Polygon.
lineSliceTakes a line, a start Point, and a stop point and returns a subsection of the line in-between those points. The start & stop points don't need to fall exactly on the line.
lineSliceAlongTakes a line, a specified distance along the line to a start Point, and a specified distance along the line to a stop point and returns a subsection of the line in-between those points.
lineSplitSplit a LineString by another GeoJSON Feature.
lineToPolygonConverts (Multi)LineString(s) to Polygon(s).
maskTakes polygons or multipolygons and an optional mask, and returns an exterior ring polygon with holes.
coordEachIterate over coordinates in any GeoJSON object, similar to Array.forEach()
coordReduceReduce coordinates in any GeoJSON object, similar to Array.reduce()
propEachIterate over properties in any GeoJSON object, similar to Array.forEach()
propReduceReduce properties in any GeoJSON object into a single value, similar to how Array.reduce works. However, in this case we lazily run the reduction, so an array of all properties is unnecessary.
featureEachIterate over features in any GeoJSON object, similar to Array.forEach.
featureReduceReduce features in any GeoJSON object, similar to Array.reduce().
coordAllGet all coordinates from any GeoJSON object.
geomEachIterate over each geometry in any GeoJSON object, similar to Array.forEach()
geomReduceReduce geometry in any GeoJSON object, similar to Array.reduce().
flattenEachIterate over flattened features in any GeoJSON object, similar to Array.forEach.
flattenReduceReduce flattened features in any GeoJSON object, similar to Array.reduce().
segmentEachIterate over 2-vertex line segment in any GeoJSON object, similar to Array.forEach() (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
segmentReduceReduce 2-vertex line segment in any GeoJSON object, similar to Array.reduce() (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
lineEachIterate over line or ring coordinates in LineString, Polygon, MultiLineString, MultiPolygon Features or Geometries, similar to Array.forEach.
lineReduceReduce features in any GeoJSON object, similar to Array.reduce().
findSegmentFinds a particular 2-vertex LineString Segment from a GeoJSON using @turf/meta indexes.
findPointFinds a particular Point from a GeoJSON using @turf/meta indexes.
midpointTakes two points and returns a point midway between them. The midpoint is calculated geodesically, meaning the curvature of the earth is taken into account.
moranIndexMoran's I measures patterns of attribute values associated with features. The method reveal whether similar values tend to occur near each other, or whether high or low values are interspersed.
nearestNeighborAnalysisNearest Neighbor Analysis calculates an index based on the average distances between points in the dataset, thereby providing inference as to whether the data is clustered, dispersed, or randomly distributed within the study area.
nearestPointTakes a reference point and a FeatureCollection of Features with Point geometries and returns the point from the FeatureCollection closest to the reference. This calculation is geodesic.
nearestPointOnLineReturns the nearest point on a line to a given point.
nearestPointToLineReturns the closest point, of a collection of points, to a line. The returned point has a dist property indicating its distance to the line.
planepointTakes a triangular plane as a polygon and a point within that triangle, and returns the z-value at that point.
pointGridCreates a grid of points
pointOnFeatureTakes a Feature or FeatureCollection and returns a Point guaranteed to be on the surface of the feature.
pointToLineDistanceCalculates the distance between a given point and the nearest point on a line. Sometimes referred to as the cross track distance.
pointToPolygonDistanceCalculates the distance from a point to the edges of a polygon or multi-polygon. Returns negative values for points inside the polygon. Handles polygons with holes and multi-polygons. A hole is treated as the exterior of the polygon.
pointsWithinPolygonFinds Points or MultiPoint coordinate positions that fall within (Multi)Polygon(s).
polygonSmoothSmooths a Polygon or MultiPolygon. Based on Chaikin's algorithm. Warning: may create degenerate polygons.
polygonTangentsFinds the tangents of a (Multi)Polygon from a Point.
polygonToLineConverts a Polygon to (Multi)LineString or MultiPolygon to a FeatureCollection of (Multi)LineString.
polygonizePolygonizes (Multi)LineString(s) into Polygons.
toMercatorConverts a WGS84 GeoJSON object into Mercator (EPSG:900913) projection
toWgs84Converts a Mercator (EPSG:900913) GeoJSON object into WGS84 projection
quadratAnalysisQuadrat analysis lays a set of equal-size areas(quadrat) over the study area and counts the number of features in each quadrat and creates a frequency table. The table lists the number of quadrats containing no features, the number containing one feature, two features, and so on, all the way up to the quadrat containing the most features. The method then creates the frequency table for the random distribution, usually based on a Poisson distribution. The method uses the distribution to calculate the probability for 0 feature occuring, 1 feature occuring, 2 features, and so on, and lists these probabilities in the frequency table. By comparing the two frequency tables, you can see whether the features create a pattern. If the table for the observed distribution has more quadrats containing many features than the table for the random distribution dose, then the features create a clustered pattern.
randomPositionReturns a random position within a bounding box.
randomPointReturns a random point.
randomPolygonReturns a random polygon.
randomLineStringReturns a random LineString.
rectangleGridCreates a grid of rectangular polygons with width and height consistent in degrees
rewindRewind LineString|(Multi)LineString or Polygon|(Multi)Polygon outer ring counterclockwise and inner rings clockwise (Uses [Formula](http://en.wikipedia.org/wiki/Shoelace_formula
rhumbBearingTakes two Point|points and finds the bearing angle between them along a Rhumb line i.e. the angle measured in degrees start the north line (0 degrees)
rhumbDestinationReturns the destination Point having travelled the given distance along a Rhumb line from the origin Point with the (varant) given bearing.
rhumbDistanceCalculates the distance along a rhumb line between two Point|points in Units
sampleTakes a FeatureCollection and returns a FeatureCollection with given number of Feature|features at random.
sectorCreates a circular sector of a circle of given radius and center Point, between (clockwise) bearing1 and bearing2; 0 bearing is North of center point, positive clockwise.
shortestPathReturns the shortest path from Point|start to Point|end without colliding with any Feature in obstacles FeatureCollection<Polygon>
simplifySimplifies the geometries in a GeoJSON object. Uses the 2d version of simplify-js.
squareTakes a bounding box and calculates the minimum square bounding box that would contain the input.
squareGridCreates a grid of square polygons with cell length consistent in degrees
standardDeviationalEllipseTakes a collection of features and returns a standard deviational ellipse, also known as a “directional distribution.” The standard deviational ellipse aims to show the direction and the distribution of a dataset by drawing an ellipse that contains about one standard deviation’s worth (~ 70%) of the data.
tagTakes a set of points and a set of polygons and/or multipolygons and performs a spatial join.
tesselateTesselates a polygon or multipolygon into a collection of triangle polygons using earcut.
tinTakes a set of points and creates a Triangulated Irregular Network, or a TIN for short, returned as a collection of Polygons. These are often used for developing elevation contour maps or stepped heat visualizations.
transformRotateRotates any geojson Feature or Geometry of a specified angle, around its centroid or a given pivot point.
transformScaleScale GeoJSON objects from a given point by a scaling factor e.g. factor=2 would make each object 200% larger. If a FeatureCollection is provided, the origin point will be calculated based on each individual feature unless an exact
transformTranslateMoves any geojson Feature or Geometry of a specified distance along a Rhumb Line on the provided direction angle.
triangleGridCreates a grid of triangular polygons.
truncateTakes a GeoJSON Feature or FeatureCollection and truncates the precision of the geometry.
unionTakes a collection of input polygons and returns a combined polygon. If the input polygons are not contiguous, this function returns a multi-polygon feature.
unkinkPolygonTakes a kinked polygon and returns a feature collection of polygons that have no kinks.
voronoiTakes a collection of points and a bounding box, and returns a collection of Voronoi polygons.

变量

变量描述
earthRadiusThe Earth radius in meters. Used by Turf modules that model the Earth as a sphere. The mean radius was selected because it is recommended by the Haversine formula (used by turf/distance) to reduce error.
factorsUnit of measurement factors based on earthRadius.
areaFactorsArea of measurement factors based on 1 square meter.

命名空间

命名空间描述
clusters-
helpers-
invariant-
meta-
projection-
random-

接口

接口描述
NearestNeighborStatisticsNearest neighbour statistics.
NearestNeighborStudyAreaNearest neighbour study area polygon feature.
QuadratAnalysisResult-

类型别名

类型别名描述
IdId
Coord-
UnitsLinear measurement units.
AreaUnitsArea measurement units.
GridGrid types.
CornersShorthand corner identifiers.
LinesGeometries made up of lines i.e. lines and polygons.
AllGeoJSONConvenience type for all possible GeoJSON.

KBE3D @3.0.0 Copyright © 2024-present KBE3D